package androidx.core.app;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

public class a extends b.f.d.a {

    /* renamed from: c  reason: collision with root package name */
    private static c f517c;

    /* renamed from: androidx.core.app.a$a  reason: collision with other inner class name */
    static class C0013a implements Runnable {

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ String[] f518b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ Activity f519c;

        /* renamed from: d  reason: collision with root package name */
        final /* synthetic */ int f520d;

        C0013a(String[] strArr, Activity activity, int i) {
            this.f518b = strArr;
            this.f519c = activity;
            this.f520d = i;
        }

        public void run() {
            int[] iArr = new int[this.f518b.length];
            PackageManager packageManager = this.f519c.getPackageManager();
            String packageName = this.f519c.getPackageName();
            int length = this.f518b.length;
            for (int i = 0; i < length; i++) {
                iArr[i] = packageManager.checkPermission(this.f518b[i], packageName);
            }
            ((b) this.f519c).onRequestPermissionsResult(this.f520d, this.f518b, iArr);
        }
    }

    public interface b {
        void onRequestPermissionsResult(int i, String[] strArr, int[] iArr);
    }

    public interface c {
        boolean a(Activity activity, String[] strArr, int i);

        boolean b(Activity activity, int i, int i2, Intent intent);
    }

    public interface d {
        void a(int i);
    }

    public static void f(Activity activity) {
        if (Build.VERSION.SDK_INT >= 16) {
            activity.finishAffinity();
        } else {
            activity.finish();
        }
    }

    public static c g() {
        return f517c;
    }

    public static void h(Activity activity) {
        if (Build.VERSION.SDK_INT >= 28 || !b.i(activity)) {
            activity.recreate();
        }
    }

    public static void i(Activity activity, String[] strArr, int i) {
        c cVar = f517c;
        if (cVar != null && cVar.a(activity, strArr, i)) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 23) {
            if (activity instanceof d) {
                ((d) activity).a(i);
            }
            activity.requestPermissions(strArr, i);
        } else if (activity instanceof b) {
            new Handler(Looper.getMainLooper()).post(new C0013a(strArr, activity, i));
        }
    }

    public static boolean j(Activity activity, String str) {
        if (Build.VERSION.SDK_INT >= 23) {
            return activity.shouldShowRequestPermissionRationale(str);
        }
        return false;
    }

    public static void k(Activity activity, Intent intent, int i, Bundle bundle) {
        if (Build.VERSION.SDK_INT >= 16) {
            activity.startActivityForResult(intent, i, bundle);
        } else {
            activity.startActivityForResult(intent, i);
        }
    }

    public static void l(Activity activity, IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4, Bundle bundle) {
        if (Build.VERSION.SDK_INT >= 16) {
            activity.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
        } else {
            activity.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4);
        }
    }
}
